<?php defined('SYSPATH') or die('No direct script access.');
	
	class Controller_Statistics extends Controller{
		
		public function action_index(){
									
			$actions = array();
			$actions[] = array("url"=>"/diastole/statistics/dataset","text"=>"Datos Generales");
			//$actions[] = array("url"=>"/diastole/statistics/aod","text"=>"Amplitud Diastólica");
			//$actions[] = array("url"=>"/diastole/statistics/aos","text"=>"Ancho Sistólico");
			//$actions[] = array("url"=>"/diastole/statistics/iar","text"=>"Aumentación Radial");
						
			//Tabs creation
			$new_tabs = View::factory("components/tabs");
			$new_tabs->actions = $actions;
			
			$statistics_view = View::factory("statistics");
			$statistics_view->statistics_content = $new_tabs->render();
			
			$this->request->response = $statistics_view->render();
		}
		
		
		public function action_dataset(){
			$grid = new Jqgrid("statistics", Helper_Service::factory("statistics"));
			
			$statistics = View::factory("page");
			$statistics->page_content = $grid->render("jqgrid/config/statistics");
			
			$this->request->response = $statistics->render();
		}
		
		
		public function action_list(){
			$grid = new Jqgrid("statistics", Helper_Service::factory("statistics"));
			
			$criteria = new Jqgrid_Criteria();
			$criteria->page = $_POST['page'];
			$criteria->limit = $_POST['rows'];
			$criteria->sidx = $_POST['sidx'];
			$criteria->sord = $_POST['sord'];
			
			if (isset($_POST['_search'])){
				if (($search = $_POST['_search']) == "true"){
					$criteria->isSearch = true;
					$criteria->searchField = $_POST['searchField'];
					$criteria->searchOper = $_POST['searchOper'];
		 			$criteria->searchString = $_POST['searchString'];
				}
			}
			
			$this->request->response = $grid->getList($criteria);
		}
		
		public function action_aod(){
			$aod_chart = View::factory("statistics-charts/aod-chart");
			$aod_chart->stats_data = Helper_Service::factory("statistics")->getList(); 
			$this->request->response = $aod_chart->render();
		}
		
		public function action_aos(){
			
		}
		
		public function action_iar(){
			
		}
		
		
		public function action_search(){
			   
		}
		
		
	}
?>